/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package crm.salesOrderProcessing.entity;

import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import scm.rawMaterialPurchasing.entity.BOMEntity;

/**
 *
 * @author frankxgz
 */
@Entity
public class ProductEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private double basePrice;
    private double promotionPrice;
    private int promotionQuantity;
    private String productName;
    private String warehouseLocation;
    @OneToOne(targetEntity = BOMEntity.class, cascade={CascadeType.ALL})
    private BOMEntity billOfMaterials;
    
    
    public ProductEntity(){
        setId(System.nanoTime());
    }
    
    public void create(double basePrice, double promotionPrice, String productName){
        this.setBasePrice(basePrice);
        this.setPromotionPrice(promotionPrice);
        this.setProductName(productName);
    }
 
    
 
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProductEntity)) {
            return false;
        }
        ProductEntity other = (ProductEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sales.entity.Product[ id=" + id + " ]";
    }

    /**
     * @return the basePrice
     */
    public double getBasePrice() {
        return basePrice;
    }

    /**
     * @param basePrice the basePrice to set
     */
    public void setBasePrice(double basePrice) {
        this.basePrice = basePrice;
    }

    /**
     * @return the promotionPrice
     */
    public double getPromotionPrice() {
        return promotionPrice;
    }

    /**
     * @param promotionPrice the promotionPrice to set
     */
    public void setPromotionPrice(double promotionPrice) {
        this.promotionPrice = promotionPrice;
    }

    /**
     * @return the productName
     */
    public String getProductName() {
        return productName;
    }

    /**
     * @param productName the productName to set
     */
    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getWarehouseLocation() {
        return warehouseLocation;
    }

    public void setWarehouseLocation(String warehouseLocation) {
        this.warehouseLocation = warehouseLocation;
    }

    public BOMEntity getBillOfMaterials() {
        return billOfMaterials;
    }

    public void setBillOfMaterials(BOMEntity billOfMaterials) {
        this.billOfMaterials = billOfMaterials;
    }

    /**
     * @return the promotionQuantity
     */
    public int getPromotionQuantity() {
        return promotionQuantity;
    }

    /**
     * @param promotionQuantity the promotionQuantity to set
     */
    public void setPromotionQuantity(int promotionQuantity) {
        this.promotionQuantity = promotionQuantity;
    }
    
}
